In this code I want to insert some HTML and normal text in JavaScript and don't want it to always enter document.write(" in starting of each line like this:
document.write ("<Style>");
document.write ("html {height:100%}");
document.write (".header {background-color: Aliceblue}");
document.write ("</Style>");
document.write ("<Div class='header'>Website Name</div>");
document.write ("<P style='color:red'>Some text i gathered here</p>");
It'll be very helpful if someone could solve this problem or give me some alternative.😊😊😊
document.write(`
<style>
html {height:100%}
.header {background-color: Aliceblue}"
</style>
<div class="header">Website Name</div>
<p style="color:red">Some text i gathered here</p>
`)
<script>
function write(data) {
document.write(data)
}
</script>
...
<script>
write("<style>");
write("html {height:100%}");
...
</script>
Warning:
<Style> -> wrong
<style> -> ok
"<div class="header">Website Name</div>" -> err
"<div class='header'>Website Name</div>" -> ok